//
//  CunQuDetailModel.m
//  ProjectforHDX
//
//  Created by yinda on 2018/6/20.
//  Copyright © 2018年 H.DX. All rights reserved.
//

#import "CunQuDetailModel.h"

@implementation CunQuDetailModel
-(void)encodeWithCoder:(NSCoder *)aCoder{
    
    NSArray *names = [NSArray gethdxProperties:[self class]];
    for (NSString *name in names) {
        id value = [self valueForKey:name];
        
        [aCoder encodeObject:value  forKey:name];
    }
    
}

-(id)initWithCoder:(NSCoder *)aDecoder{
    self = [super init];
    if (self) {
        //        self.userID =  [aDecoder decodeObjectForKey:@"userID"];
        //获取所有属性 ，遍历 给属性赋值
        NSArray *names = [NSArray gethdxProperties:[self class]];
        for (NSString *name in names) {
            
            [self  setValue:[aDecoder decodeObjectForKey:name] forKey:name];
            
        }
        
    }
    return self;
}

-(void)setAttributes:(NSDictionary *)userInfo{
    
    
    [super setAttributes:userInfo];
    //获取所有属性 ，遍历 给属性赋值
    NSArray *names = [NSArray gethdxProperties:[self class]];
    for (NSString *name in names) {
        if([[userInfo allKeys] containsObject:name]){
            if([name isEqualToString:@"open"]){
                if(1==[[userInfo objectForKey:name] intValue]){
                    [self setValue:@YES forKey:name];
                }
                else{
                    [self setValue:@NO forKey:name];
                }
            }
            else{
                [self  setValue:[userInfo objectForKey:name] forKey:name];
            }
        }
        else{
            if([name isEqualToString:@"open"]){
                [self  setValue:@NO  forKey:name];
            }
            else{
                //                   if([name isEqualToString:@"process"]){
                //                       [self  setValue:@[] forKey:name];
                //                   }
                //                   else{
                [self  setValue:@""  forKey:name];
                //                   }
                
                
                
                
            }
        }
    }
    
}
@end
